package huawei;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * BOSS的收入
 */
public class BossIncome
{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();

        Map<Integer, Person> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int pid = sc.nextInt();
            int money = sc.nextInt();

            map.put(id, new Person(id, pid, money));
        }

        BossIncome bossIncome = new BossIncome();

        System.out.print(0);
        System.out.print(" ");
        DecimalFormat df = new DecimalFormat("#");
        System.out.println(df.format(bossIncome.solution(map)));
    }

    public float solution(Map<Integer, Person> map) {
        float bossIncome = 0;

        for (Map.Entry<Integer, Person> entry : map.entrySet()) {
            Person person = entry.getValue();
            Integer pid = person.pid;

            if (pid == 0) {
                bossIncome += person.money * 0.15f;
            } else {
                float money = person.money;
                while (pid != 0) {
                    money *= 0.15f;
                    Person p = map.get(pid);
                    pid = p.pid;
                }
                bossIncome += money * 0.15f;
            }
        }
        return bossIncome;
    }

    public static class Person {
        Integer id;
        Integer pid;
        Integer money;

        public Person(Integer id, Integer pid, Integer money) {
            this.id = id;
            this.pid = pid;
            this.money = money;
        }
    }

}
